import React, { Component } from 'react';
import { Toast, Form, Input, Button } from 'antd-mobile'
import { withRouter } from 'react-router-dom';
import service from '../../api'
class Reg1 extends Component<any> {
    onFinish(values: any) {
        console.log(values)
        localStorage.setItem('tel',values.tel)
        service.user.doCheckPhone(values).then(res => {
            console.log(res)
            if (res.data.code === '200') {
                this.props.history.push('/register/reg2')
            }
            else {
                Toast.show({
                    content: res.data.message
                })
            }
        })
    }
    render() {
        return (
            <div>
                <Form layout='horizontal'
                    // mode='card'
                    onFinish={this.onFinish.bind(this)}
                    footer={
                        <Button block type='submit' shape='rounded' color='danger' size='large'>
                            下一步
                        </Button>
                    }
                >
                    <Form.Item label='' validateFirst name='tel' rules={[{ required: true, message: '请输入手机号' },
                    { pattern: /^1[34578]\d{9}$/, message: '请输入正确手机号' }
                    ]}>
                        <Input placeholder='请输入手机号' clearable />
                    </Form.Item>
                </Form>
            </div>
        );
    }
}

export default withRouter(Reg1);